import java.util.Stack;
//逆波兰表达式
public class demo20 {
    class Solution {
        public int evalRPN(String[] s) {
            Stack<Integer> s1 = new Stack<>();
            Integer t1 = 0,t2 = 0;
            for(String st : s)
            {
                switch(st)
                {
                    case"+":
                        t2 = s1.pop();
                        t1 = s1.pop();
                        s1.push(t1+t2);
                        break;

                    case"-":
                        t2 = s1.pop();
                        t1 = s1.pop();
                        s1.push(t1-t2);
                        break;

                    case"*":
                        t2 = s1.pop();
                        t1 = s1.pop();
                        s1.push(t1*t2);
                        break;

                    case"/":
                        t2 = s1.pop();
                        t1 = s1.pop();
                        s1.push(t1/t2);
                        break;

                    default :
                        s1.push(Integer.valueOf(st));
                        break;
                }
            }
            return s1.pop();
        }
    }
}
